<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>门店会员管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			suo();
			findtemplate();
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function findtemplate() {
			var city=$("#cit").val();
			var province=$("#province").val();
		    $.ajax({
		        type : "post",
		        async : false,
		        url : "${ctx}/sys/yongUser/cityData",
		        data : {
		            'id' : province
		        },
		        dataType : "json",
		        success : function(msg) {
		            $("#city").empty();
		            $('#s2id_city').find('.select2-chosen').text('所在市');
		            //$('#s2id_city').append('<option selected="selected" value="">所在市</option>')
		            //$("#template").select2();
		            if (msg.length > 0) {
		                for (var i = 0; i < msg.length; i++) {
		                        var partId = msg[i].id;
		                        var partName = msg[i].name;
		                        
		                        if(city==partId){
			        
			                    	   var $option = $("<option selected='selected'>").attr({
				                            "value" : partId
				                        }).text(partName);
			                    }else{
		                        var $option = $("<option>").attr({
		                            "value" : partId
		                        }).text(partName);
			                    }
		                        $("#city").append($option);
		                }
		                //$("#template option:first").prop("selected", 'selected');
		                $("#city").change();

		            }
		        },
		        error : function(json) {
		            $.jBox.alert("网络异常！");
		        }
		    });
		}
		
		function userStoreType(){
			var id=$("#suoStore").val();
			$.ajax({
				type:"post",
				url: "${ctx}/sys/store/storeType",
				data:{"id":id},
				dataType: "json",
				success:function(data){
					var data=data.type;
					if(data!=null && data!=""){
						var stg=$("#type").val(data);
						var ss=$("#type").val();
						if(data==2){
						$('#s2id_type').find('.select2-chosen').text("第三方");
						}
						if(data==1){
							$('#s2id_type').find('.select2-chosen').text("自营");
						}
						
					}else{
						$('#s2id_type').find('.select2-chosen').text("所有");
					}
					
				}
			})
		}
		
		function suo(){
			var type=$("#type").val();
			var buyStore=$("#sto").val();
			$.ajax({
		        type : "post",
		        async : false,
		        url : "${ctx}/sys/yongUser/storeList",
		        data : {
		            'type' : type
		        },
		        dataType : "json",
		        success : function(msg) {
		            $("#suoStore").empty();
		            
		             $('#suoStore').append('<option selected="selected" value="">所属门店</option>')
		             
		            //$("#template").select2();
		            if (msg.length > 0) {
		                for (var i = 0; i < msg.length; i++) {
		                        var partId = msg[i].id;
		                        var partName = msg[i].cnName;
		                        if(buyStore==partId){
			             		       
			                    	   var $option = $("<option selected='selected'>").attr({
				                            "value" : partId
				                        }).text(partName);
			                    }else{
		                        var $option = $("<option>").attr({
		                            "value" : partId
		                        }).text(partName);
			                    }
		                        $("#suoStore").append($option);
		                }
		                $("#suoStore").change();

		            }
		        },
		        error : function(json) {
		            $.jBox.alert("网络异常！");
		        }
		    });
		}
		
	</script>
</head>
<body>
   <input id="sto" value="${user.suoStore }" type="hidden"/>
   <input id="cit" value="${user.city }" type="hidden"/>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/yongUser/">门店会员信息</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="yongUser" action="${ctx}/sys/yongUser/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
		    <tr>
		    <td>
			<li><label>企业名称：</label>
				<form:input path="company" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			</td>
			<td>
			<li><label>企业类型：</label>
				<form:select id="companyType" path="companyType" class="input-medium">
			    <form:option value="" label="请选择企业类型"/>
			    <form:options items="${fns:getDictList('company_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</li>
			</td>
			<%-- <li><label>所在地区：</label>
				<form:select id="companyType" path="companyType" class="input-medium">
			    <form:option value="" label="请选择企业类型"/>
			    <form:options items="${fns:getDictList('company_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</li> --%>
			<td>
			<li>   
            <label>所在地区:</label>
                 <form:select id="province" path="province" class="input-medium" onchange="findtemplate()">
			     <form:option value="" label="所在省"/>
			     <form:options items="${province}" htmlEscape="false" itemValue="id" itemLabel="name"/>
			     </form:select>
			     
			     <form:select id="city" path="city" class="input-medium" >
			    <%--  <form:option value="" label="所在市"/> --%>
			     <%-- <form:options items="${province}" htmlEscape="false" itemValue="id" itemLabel="name"/> --%>
			     </form:select>
			</li>
			</td>
			</tr>
			<tr>
			<td>
			<li><label>门店类型：</label>
		        <form:select id="type" path="type" class="input-medium" onchange="suo()">
				<form:option value="" label="所有"/>
			    <form:options items="${fns:getDictList('store_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</li>
			</td>
			<td>
			<li><label>所属门店：</label><form:select id="suoStore" path="suoStore" class="input-medium" >
			<form:option value="" label="所属门店"/>
			<%-- <form:options items="${store}" htmlEscape="false" itemValue="id" itemLabel="cnName" /> --%>
			</form:select>
			</li>
			</td>
			<td>
			 <li><label>企业认证时间：</label>
				<input name="startTime" type="text" readonly="readonly" placeholder="开始时间" class="input-medium Wdate " 
					value="<fmt:formatDate value="${yongUser.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/>"
			         onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			     &nbsp;&nbsp;&nbsp;&nbsp;
			     <input name="endTime" type="text" readonly="readonly" placeholder="结束时间" class="input-medium Wdate " 
					value="<fmt:formatDate  value="${yongUser.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/>"
			     onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> 
			</li> 
			</td>
		    </tr>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<div style="display:none;">
		<sys:message content="${message}"/>
	</div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			    <th>序号</th>
				<th>用户名</th>
				<th>手机号</th>
				<th>企业名称</th>
				<th>企业类型</th>
				<th>所在地区</th>
				<th>企业认证时间</th>
				<th>下单门店</th>
				<th>所属门店</th>
				<th>所属业务员</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="yongUser" varStatus="status">
			<tr>
			    <td>${status.index+1 }</td>
				<td>${yongUser.name}</td>
				<td>${yongUser.mobile }</td>
				<td>${yongUser.company }</td>
				<td>${fns:getDictLabel(yongUser.companyType, 'company_type', '')}</td>
				<td>${yongUser.address }</td>
				<td><fmt:formatDate value="${yongUser.companyCreateTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
				<td>${yongUser. xiaStore}</td>
				<td>${yongUser.suoStore }</td>
				<td>${yongUser.salMan }</td>
				
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>